package com.wva.video.controller;

import cn.hutool.core.util.StrUtil;
import com.wva.common.domain.dto.PageQueryDTO;
import com.wva.common.domain.vo.PageQueryVO;
import com.wva.common.utils.R;
import com.wva.video.domain.vo.VideoItemDTO;
import com.wva.video.service.VideoCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: hong
 * @Date: 2025/2/16 00:00:24
 */
@Api(tags = "视频收藏相关接口")
@RequestMapping("/video/collect")
@RestController
public class CollectController {
    @Resource
    VideoCollectService videoCollectService;

    @ApiOperation("获取用户已收藏视频")
    @GetMapping("/list")
    R<PageQueryVO<VideoItemDTO>> list(PageQueryDTO pageQueryDTO) {
        //查询数据库中用户收藏的视频
        if (StrUtil.isEmpty(pageQueryDTO.getSortBy())) pageQueryDTO.setSortBy("update_time");
        PageQueryVO<VideoItemDTO> videos = videoCollectService.listUserCollectVideoByPage(pageQueryDTO);
        return R.ok(videos);
    }
}
